using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Commerce.Common;

namespace CategoryProductPicker
{
    public partial class ProductPicker : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
    {
        public string productId;

        protected void Page_Load(object sender, EventArgs e)
        {
            Commerce.Common.ProductCollection products = null;

            products = new ProductCollection().Load();

            foreach (Product thisProd in products)
            {
                ListItem item = new ListItem();
                item.Text = thisProd.ProductName;
                item.Value = thisProd.ProductID.ToString();
                productDDL.Items.Add(item);
            }
        }

        protected void productDDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            productId = productDDL.SelectedIndex.ToString();
        }

        #region IUsercontrolDataEditor Members

        public object value
        {
            get
            {
                return productId;
            }
            set
            {
                productId = value.ToString();
            }
        }

        #endregion


    }
}